#include <Rectangle.h>

Rectangle::Rectangle(TypeLength &length,TypeLength &width):m_Length(length),m_Width(width)
{

};

Rectangle::Rectangle(TypeLength &length):m_Length(length),m_Width(length)
{

};

double Rectangle::getArea(void) const
{
	if (isValidRectangle())
	{
		TypeLength cOutput(m_Length.getInputValue() * m_Width.getInputValue());
		return cOutput.getOutputValue();
	}
	else
		return 0;
}

double Rectangle::getPerimeter(void) const
{
	if (isValidRectangle())
	{
		TypeLength cOutput((m_Length.getInputValue() + m_Width.getInputValue()) * 2);
		return cOutput.getOutputValue();
	}
	else
		return 0;
}

void Rectangle::setLength(TypeLength &length)
{
	if(length.getInputValue()!=0)
		m_Length = length;
}

void Rectangle::setWidth(TypeLength &width)
{
	if(width.getInputValue()!=0)
		m_Width = width;
}

bool Rectangle::isValidRectangle(void) const
{
	return ((m_Length.getInputValue() != 0) && (m_Width.getInputValue() != 0));
}
